package com.qiankan.qmsj.utils;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.signature.StringSignature;

public class AsyncLoadImage {

    //加载网络图片第一种方法,加signature避免url相同，图片改变
    public static void loadImage(String url, ImageView v) {
        Glide.with(v.getContext()).load(url).crossFade().thumbnail(0.1f).skipMemoryCache(true)
                .signature(new StringSignature(System.currentTimeMillis() + "")).into(v);
    }

    public static void loadImage(String url, ImageView v, int resourceId) {
        Glide.with(v.getContext()).load(url).placeholder(resourceId).crossFade().thumbnail(0.1f).skipMemoryCache(true)
                .signature(new StringSignature(System.currentTimeMillis() + "")).into(v);
    }

    public static void loadImageRound(String url, ImageView v) {
        Glide.with(v.getContext()).load(url).dontAnimate().thumbnail(0.1f).skipMemoryCache(true).transform(new GlideCircleTransform(v.getContext()))
                .signature(new StringSignature(System.currentTimeMillis() + "")).into(v);
    }

    /*加载图片，url不变时也可更新图片*/
    public static void loadImageRoundWithSign(String url, ImageView v, int resourceId) {
        Glide.with(v.getContext()).load(url).placeholder(resourceId).dontAnimate().thumbnail(0.1f).skipMemoryCache(true).transform(new GlideCircleTransform(v.getContext()))
                .signature(new StringSignature(System.currentTimeMillis() + "")).into(v);
    }

    /*加载图片，url不变时不更新图片*/
    public static void loadImageRound(String url, ImageView v, int resourceId) {
        Glide.with(v.getContext()).load(url).placeholder(resourceId).dontAnimate().thumbnail(0.1f).skipMemoryCache(true).transform(new GlideCircleTransform(v.getContext())).into(v);
    }
}
